package com.example.springbootdemo.vo;

import lombok.Data;

@Data
public class ResultVo<T> {
    private int code;
    private String msg;
    private T Data;
    private final static String SUCCESS_MSG = "SUCCESS";
    private final static String ERROR_MSG = "ERROR";
    private final static int ERROR_CODE = -1;
    private final static int SUCCESS_CODE = 200;

    public static <T> ResultVo<T> success(T data) {
        ResultVo<T> result = new ResultVo();
        result.setCode(SUCCESS_CODE);
        result.setMsg(SUCCESS_MSG);
        result.setData(data);
        return result;
    }

    public static ResultVo error(Object data) {
        ResultVo result = new ResultVo();
        result.setCode(ERROR_CODE);
        result.setMsg(ERROR_MSG);
        result.setData(data);
        return result;
    }
}
